package io.chain.ko.util;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;

public class AuthUtils {
	
	public static List<SimpleGrantedAuthority> buildAuth(String roles){
		List<SimpleGrantedAuthority> authorities=new ArrayList<>();
		if(StringUtils.isNotEmpty(roles)) {
			String roleArr[]=StringUtils.splitByWholeSeparator(roles,",");
			for(String role:roleArr) {
				authorities.add(new SimpleGrantedAuthority(role));
			}
		}
		return authorities;
	}
	
}
